
<template>
  <div class="main-container">
    <div class="filtrate-bar">
      <div class="title-box">
        <div class="icon-box">
          <span class="iconfont icon-yuangong" />
        </div>
        <span class="text">人事统计报告</span>
      </div>
    </div>

    <div class="table-content">
      <div class="handle-bar">
        <a-button class="export-btn">导出</a-button>
      </div>
      <a-table :scroll="{ y: 300 }" :columns="fieldList" :data-source="tableList" bordered :pagination="false">
      </a-table>
    </div>

    <div class="analysis">
      <a-row :span="24">
        <a-col :span="24"
          ><div class="analysis-content">
            <div id="analysisBu1" /></div
        ></a-col>
      </a-row>
    </div>

    <div class="content"></div>
  </div>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
export default {
  /** 客户总量分析 */
  name: 'HrReportAll1',
  data() {
    return {
      loading: false,
      chartAnalysis1: null,
      analysis1Option: {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        legend: {
          data: ['北京分公司', '成都分公司', '南京分公司', '浙江分公司', '福建分公司'],
          bottom: 0,
        },
        toolbox: {
          show: true,
          orient: 'vertical',
          left: 'right',
          top: 'center',
          feature: {
            mark: { show: true },
            dataView: { show: true, readOnly: false },
            magicType: { show: true, type: ['line', 'bar', 'stack', 'tiled'] },
            restore: { show: true },
            saveAsImage: { show: true },
          },
        },
        xAxis: [
          {
            type: 'category',
            data: ['2021-6月期初人数-正式', '2021-6月期初人数-实习', '2021-6月期末人数-正式', '2021-6月期末人数-实习', '2021-6月离职人数','期末总人数'],
          },
        ],
        yAxis: [
          {
            type: 'value',
          },
        ],
        series: [
          {
            name: '北京分公司',
            type: 'bar',
            barGap: '30%',
            emphasis: {
              focus: 'series',
            },
            data: [320, 332, 301, 334, 390],
          },
          {
            name: '成都分公司',
            type: 'bar',
            barGap: '30%',
            emphasis: {
              focus: 'series',
            },
            data: [220, 182, 191, 234, 290],
          },
          {
            name: '南京分公司',
            type: 'bar',
            barGap: '30%',
            emphasis: {
              focus: 'series',
            },
            data: [150, 232, 201, 154, 190],
          },
          {
            name: '浙江分公司',
            type: 'bar',
            barGap: '30%',
            emphasis: {
              focus: 'series',
            },
            data: [98, 77, 101, 99, 40],
          },
          {
            name: '福建分公司',
            type: 'bar',
            barGap: '30%',
            emphasis: {
              focus: 'series',
            },
            data: [98, 77, 101, 99, 40],
          },
        ],
      },
      //analysis2Option: null,
      analysis3Option: null,

      url: {
        getSalesDataTotalAnalysis: '/online/api/getSalesDataTotalAnalysis',
        exportXlsUrl: '/online/api/export/exportXlsGraphReport',
      },
      postParams: {}, // 筛选参数
      dataIndex: null,
      list: [],
      axisList: [],
      fieldList: [
        {
          title: '2021年5月离职率统计计算表',
          children: [
            {
              title: '部门',
              align: 'center',
              width: 150,
              dataIndex: 'item1',
              key: 'item1',
            },

            {
              title: '2021年5月期初人数',
              align: 'center',
              children: [
                {
                  title: '正式',
                  align: 'center',
                  width: 150,
                  dataIndex: 'item2',
                  key: 'item2',
                },
                {
                  title: '实习',
                  align: 'center',
                  width: 150,
                  dataIndex: 'item3',
                  key: 'item3',
                },
                {
                  title: '临时',
                  align: 'center',
                  width: 150,
                  dataIndex: 'item4',
                  key: 'item4',
                },
                {
                  title: '派遣',
                  align: 'center',
                  width: 150,
                  dataIndex: 'item4',
                  key: 'item5',
                },
              ],
            },
            {
              title: '2021年5月期末人数',
              align: 'center',
              children: [
                {
                  title: '正式',
                  align: 'center',
                  width: 150,
                  dataIndex: 'item6',
                  key: 'item6',
                },
                {
                  title: '实习',
                  align: 'center',
                  width: 150,
                  dataIndex: 'item7',
                  key: 'item7',
                },
                {
                  title: '临时',
                  align: 'center',
                  width: 150,
                  dataIndex: 'item8',
                  key: 'item8',
                },
                {
                  title: '派遣',
                  align: 'center',
                  width: 150,
                  dataIndex: 'item9',
                  key: 'item9',
                },
              ],
            },
            {
              title: '10月离职人数',
              align: 'center',
              width: 150,
              dataIndex: 'item10',
              key: 'item10',
            },
            {
              title: '期末总人数',
              width: 150,
              align: 'center',
              dataIndex: 'item11',
              key: 'item11',
            },
            {
              title: '当月离职率计算',
              align: 'center',
              width: 150,
              dataIndex: 'item12',
              key: 'item12',
            },
          ],
        },
      ],
      tableList: [
        {
          item1: '北京分公司',
          item2: '28',
          item3: '0',
          item4: '0',
          item5: '0',
          item6: '29',
          item7: '0',
          item8: '0',
          item9: '0',
          item10: '1',
          item11: '29',
          item12: '0.03',
        },
        {
          item1: '北京分公司',
          item2: '28',
          item3: '0',
          item4: '0',
          item5: '0',
          item6: '29',
          item7: '0',
          item8: '0',
          item9: '0',
          item10: '1',
          item11: '29',
          item12: '0.03',
        },
        {
          item1: '北京分公司',
          item2: '28',
          item3: '0',
          item4: '0',
          item5: '0',
          item6: '29',
          item7: '0',
          item8: '0',
          item9: '0',
          item10: '1',
          item11: '29',
          item12: '0.03',
        },
        {
          item1: '北京分公司',
          item2: '28',
          item3: '0',
          item4: '0',
          item5: '0',
          item6: '29',
          item7: '0',
          item8: '0',
          item9: '0',
          item10: '1',
          item11: '29',
          item12: '0.03',
        },
      ],
      url: {
        reportEmployeeRecordResign: '/online/api/reportEmployeeRecordResign'
      }
    }
  },
  computed: {
    // 列表请求参数
    listPostParams() {
      const params = { ...this.postParams }

      if (this.dataIndex !== undefined && this.dataIndex !== null) {
        const dataItem = this.axisList[this.dataIndex]
        delete params.type
        params.startTime = dataItem.type
        params.endTime = dataItem.type
      }

      return params
    },
  },
  mounted() {
    this.initAxis()
  },
  methods: {
    /**
     * 搜索点击
     */
    searchClick(params) {
      this.postParams = params
      this.getRecordList()
    },
    /**
     * 获取相关列表
     */
    getRecordList(dataIndex) {
      this.dataIndex = dataIndex
      this.list = []
      this.loading = true
      biCustomerTotalListAPI(this.listPostParams)
        .then((res) => {
          this.loading = false
          const data = res.result || {}
          this.list = data.list || []
          this.getSummariesData(data.total)
        })
        .catch(() => {
          this.loading = false
        })
    },

    /** 图表 */
    initAxis() {
      this.chartAnalysis1 = this.echarts.init(document.getElementById('analysisBu1'))
      const param = {}
      getAction(this.url.reportEmployeeRecordResign, param).then((res) => {

        this.$nextTick(() => {
          this.getDataList()
        })
      })
      this.chartAnalysis1.setOption(this.analysis1Option, true)
    },

    /**
     * 导出点击
     */
    exportClick() {
      this.requestExportInfo(biCustomerTotalListExportAPI, this.listPostParams)
    },
  },
}
</script>


<style lang="less" scoped>
/deep/ .ant-table-thead > tr > th,
.ant-table-tbody > tr > td {
  padding: 10px 4px;
}
.main-container {
  border: 1px solid #e6e6e6;
  border-radius: 2px;
  background-color: white;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.filtrate-bar {
  background-color: white;
  padding: 15px 20px 5px 20px;
  margin-right: 15px;
  line-height: 34px;
  .icon-box {
    width: 34px;
    height: 34px;
    text-align: center;
    line-height: 34px;
    color: #2362fb;
    background-color: #dfe8ff;
    border-radius: 50%;
    margin-right: 10px;
    float: left;
  }
  .text {
    font-size: 17px;
    font-weight: 700;
  }
}

.content-title {
  padding: 10px 20px 5px;
  font-size: 16px;
  color: #333;
}
.analysis {
  margin-top: 10px;
  .analysis-content {
    padding: 8px 10px;
    #analysisBu1 {
      margin: 0 auto;
      width: 95%;
      height: 400px;
    }
  }
}

.axis-content {
  padding: 20px 10% 40px;
  position: relative;
  .axismain,
  #summaryAll1 {
    margin: 0 auto;
    width: 100%;
    height: 400px;
  }
}

.table-content {
  padding: 0 30px 20px 30px;
}

.export-button {
  float: right;
  margin-right: 22px;
}

// 导出操作bug
.handle-bar {
  margin-bottom: 8px;
  text-align: right;
}

.search-box {
  padding-right: 15px;
}

.radio-box {
  padding: 0 20px;
  margin-bottom: 15px;
  /deep/ .el-radio__label {
    color: #99a9bf !important;
  }
}

.static {
  padding: 0 20px;
  margin-bottom: 10px;
  .text {
    font-size: 13px;
    color: #99a9bf;
    display: inline-block;
  }
  .text:not(:last-child) {
    margin-right: 15px;
  }
}
/deep/ .ant-table-wrapper {
  border: 1px solid #ebeef5;
}
/deep/ .ant-table-placeholder {
  display: none;
}
</style>

